<template>
  <o-tree ref="oTree" style="height: 100%" v-if="treeConfig.uuid" v-bind="$attrs" :treeConfig="treeConfig"
          :toolButOptions="toolButOptions" :formMainList="formMainList"></o-tree>
</template>

<script>
import OTree from "@/components/tree/components/o-tree.vue";
import {get} from "@/utils/http/httpUtils";

export default {
  name: "olTree",
  components: {OTree},
  inject:['http'],
  props: {
    uuid: {}
  },
  data() {
    return {
      treeConfig: {},
      toolButOptions: [],
      formMainList: {}
    }
  },
  methods: {
    init() {
      get(this.http,'/online/treeConfig/getJson', {uuid: this.uuid}).then(({treeConfig, toolButOptions,formMainList}) => {
        treeConfig.optionJson = JSON.parse(treeConfig.optionJson);
        if (treeConfig.optionJson.optionValue) {
          for (let key of Object.keys(treeConfig.optionJson.optionValue)) {
            treeConfig[key] = treeConfig.optionJson.optionValue[key];
          }
        }
        this.treeConfig = treeConfig;
        this.toolButOptions = toolButOptions;
        this.formMainList = formMainList
      })
    }
  }, created() {
    if (this.uuid) {
      this.init();
    }
  }

}

</script>
